<!DOCTYPE html>
<html lang="en">
<head>
    <title>新建角色</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="${base}/static/res/plugin/ztree/css/style.css" type="text/css">
    <link rel="stylesheet" href="${base}/static/res/manage/css/common.css">
    <link href="${base}/static/res/manage/css/ec.css" rel="stylesheet">
    <link href="${base}/static/res/manage/css/list.css" rel="stylesheet">
    <script type="text/javascript" src="${base}/static/res/plugin/jquery/jquery-1.7.2.js"></script>
    <script type="text/javascript" src="${base}/static/res/plugin/validator/jquery.validate.min.js"></script>
    <script type="text/javascript" src="${base}/static/res/plugin/ztree/js/jquery.ztree.core-3.5.min.js"></script>
    <script type="text/javascript" src="${base}/static/res/plugin/ztree/js/jquery.ztree.excheck-3.5.min.js"></script>
    <script type="text/javascript" src="${base}/static/res/plugin/ztree/js/jquery.ztree.exedit-3.5.min.js"></script>
    <script type="text/javascript" src="${base}/static/res/admin/js/common.js"></script>
    <script type="text/javascript" src="${base}/static/res/plugin/layer/layer.js"></script>
    <script type="text/javascript" src="${base}/static/res/util/utils.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //表单验证，数据提交
            $("#inputForm").validate({
                rules: {
                    roleName: {
                        required: true,
                        maxlength: "30"
                    },
                    roleCode: {
                        required: true,
                        maxlength: "30",
                        remote: {
                            type: "post",
                            url: "validateRoleCode.jhtml",
                            dataType: "json",
                            data: {
                                roleCode: function () {
                                    return $("#roleCode").val();
                                }
                            }
                        }
                    },
                    remark: {
                        maxlength: "50"
                    },
                    status: {
                        required: true
                    }
                },
                messages: {
                    roleName: {
                        required: "必填项",
                        maxlength: "最长30个字符"
                    },
                    roleCode: {
                        required: "必填项",
                        maxlength: "最长30个字符",
                        remote: "角色编码已经存在"
                    },
                    remark: {
                        maxlength: "最长50个字符"
                    },
                    status: {
                        required: "必选项"
                    }
                },
                submitHandler: function (form) {
                    //表单提交
                    form.submit();
                }
            });

            $("#menus").click(function () {
                showLayerWin({
                    title: "选择权限",
                    iframe: {src: "/intfc/role/menuTree.jhtml"},
                    area: ["270px", "400px"],
                    closeBtn: false
                });
            });
        });
    </script>
</head>
<body>
[#--主体--]
<div class="tab set">
    <h3><a href="list.jhtml">角色管理</a>
        <a href="add.jhtml">> 新建角色</a></h3>
    <div class="tablist message set">
        <form id="inputForm" name="inputForm" action="save.jhtml" method="post">
            <input id="menuIds" name="menuIds" TYPE="hidden">
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td><label>角色名称<span class="cred"> * </span></label></td>
                    <td>
                        <input type="text" id="roleName" name="roleName" placeholder="角色名称">
                    </td>
                    <td><label>角色编码<span class="cred"> * </span></label></td>
                    <td>
                        <input type="text" id="roleCode" name="roleCode" placeholder="角色编码">
                    </td>
                </tr>

                <tr>
                    <td><label>描述</label></td>
                    <td>
                        <input type="text" id="remark" name="remark" placeholder="描述信息">
                    </td>

                    <td><label>添加权限</label></td>
                    <td>
                        <input type="text" id="menus" placeholder="点击选择权限" readonly="readonly"/>
                    </td>
                </tr>

                <tr>
                    <td><label>角色状态<span class="cred"> * </span></label></td>
                    <td>
                    [@stdCode codeType="ROLE_STATUS" all=false]
                        [#list codeMap.entrySet() as entry]
                            <label class="status">
                                <input name="status" id="status" type="radio" value="${entry.key}" class="sex">${entry.value}
                            </label>
                        [/#list]
                    [/@stdCode]
                    </td>
                </tr>
            </table>
            <p class="save">
                <input type="submit" value="保存" class="red">
                <input type="button" value="取消" id="backButton" class="red">
            </p>
        </form>
    </div>
</div>
</body>
</html>